/**
 * Created by fupeng on 17/3/12.
 */
/**
 * Created by Administrator on 2017/2/9.
 */
var pool = require('./DBConnectPool');

module.exports = {
    getMovie :function (param,callBack){
        pool.getPoolConnection('mtsc', function (err, connection) {

            if (err) {
                console.log('get connection from pool failed in Movie: ', err);
                return;
            }

            var sql = 'SELECT movie.create_time,movie.poster,movie.mid,movie.movie_name,movie.director,movie.brief,movie.cast,movie.score,movie.country,movie.category,date_format(movie.publishdate, "%Y") as publishdate,movie.movie_bigpic from ( '+ param.movietable+' ) as movie';

            connection.query(sql,function (queryErr, rows) {

                if (queryErr) {
                    console.log('select * from movie failed: ', queryErr);
                    callBack({
                        isSuccess: false
                    });
                } else {
                    callBack({
                        isSuccess: true,
                        rows: rows
                    })
                }
                connection.release();
            });

        });
    }
};

